package com.gw.vip.server.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gw.vip.common.log.PrintlnLog;
import com.gw.vip.common.vo.Result;
import com.gw.vip.server.dto.AdminRefundDto;
import com.gw.vip.server.dto.TransDto;
import com.gw.vip.server.po.ViewTrans;
import com.gw.vip.server.service.AdminTransService;
import com.gw.vip.server.vo.AdminRefundVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author GW
 * @description
 * @since 2022-07-03
 */
@RestController
@RequestMapping("adminTrans")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AdminTransController {

    private final AdminTransService adminTransService;

    @PrintlnLog(description = "交易记录")
    @PostMapping("trans")
    public Result trans(@RequestBody @Valid TransDto dto){
        IPage<ViewTrans> iPage = adminTransService.trans(dto);
        return Result.success(iPage);
    }

    @PrintlnLog(description = "网页退款")
    @PostMapping("adminRefund")
    public Result adminRefund(@RequestBody @Valid AdminRefundDto dto){
        AdminRefundVo vo = adminTransService.adminRefund(dto);
        return Result.success(vo);
    }
}
